package com.xiaoshuidi.cloud.module.report.controller.bigdata;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.module.report.controller.bigdata.vo.ApartmentIndicatorAnalysisVO;
import com.xiaoshuidi.cloud.module.report.enums.ApiConstants;
import com.xiaoshuidi.cloud.module.report.service.bigdata.IndicatorAnalysisService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.validation.constraints.NotNull;

import java.math.BigDecimal;

import static com.xiaoshuidi.cloud.framework.common.pojo.CommonResult.success;


/**
 * 合房长租公寓经营指标分析
 */
@Slf4j
@RestController
@RequestMapping(ApiConstants.PREFIX + "/indicatorAnalysis")
@Validated
@PermitAll
public class IndicatorAnalysisController {

    @Resource
    private IndicatorAnalysisService indicatorAnalysisService;

    /**
     * 集中/分散门店营收
     *
     * @param concentrated 是否集中
     * @return {@link CommonResult}<{@link ApartmentIndicatorAnalysisVO}>
     */
    @GetMapping("/apartmentRevenueByType")
    public CommonResult<ApartmentIndicatorAnalysisVO> getOverViewHouseData(
            @NotNull(message = "请传入门店类型") @RequestParam("concentrated") Integer concentrated) {
        return success(indicatorAnalysisService.apartmentRevenueByType(concentrated));
    }

    /**
     * 分散式/集中式-本月营收/年营收总额
     *
     * @param concentrated 是否集中
     * @param time         时间本年 2023 本月2028-08-01
     * @return {@link CommonResult}<{@link BigDecimal}>
     */
    @GetMapping("/revenueByTypeAndTime")
    public CommonResult<BigDecimal> revenueByTypeAndTime(
            @RequestParam(value = "concentrated",required = false) Integer concentrated,
            @RequestParam(value = "time",required = false) String time
            ) {
        return success(indicatorAnalysisService.revenueByTypeAndTime(concentrated,time));
    }


}
